// File Name: led_task.c
// Author: kukukukuku~
// Date: 2024-06-25

#include "./User/FAN/inc/fan_ctrl.h"
#include "./User/LED/inc/led_task.h"

TaskHandle_t taskHandleLed; //LED任务句柄

/**
 * @brief   LED任务
 * @param   arg:    任务参数
 * @retval  None
 * @note    None
*/
void task_led(void *arg)
{
    led_set_mode(&led1, led1.mode);
    led_set_blink_time(&led1, led1.blinkNum);
    led_set_breath_step(&led1, led1.breathStep);
    led_set_mode(&led2, led2.mode);
    led_set_blink_time(&led2, led2.blinkNum);
    led_set_breath_step(&led2, led2.breathStep);
    
    fan_on();
    
    while(1)
    {
        if(led1.mode == LED_MODE_SWITCH)
            led1Switch ? led_on(&led1) : led_off(&led1);
        
        if(led2.mode == LED_MODE_SWITCH)
            led2Switch ? led_on(&led2) : led_off(&led2);
        
        gpio_input_data_bit_read(led1.gpioPort, led1.gpioPin) ?\
        (led1.state = LED_STATE_OFF) :\
        (led1.state = LED_STATE_ON);
        
        gpio_input_data_bit_read(led2.gpioPort, led2.gpioPin) ?\
        (led2.state = LED_STATE_OFF) :\
        (led2.state = LED_STATE_ON);
        
        vTaskDelay(10);
    }
}
